Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes for at-view and at-views #20247

Merged
merged 2 commits into from
Jan 27, 2017
Merged

Conversation

stevengj
Copy link
Member

@stevengj stevengj commented Jan 26, 2017

This fixes several problems in the @view and @views (#20164) macros:

  • @view had a hygiene bug, because it used the symbol Base in the caller's scope.
  • @view A[1:end] evaluated A twice, which is a problem e.g. if A is an expression with side effects. Similarly for @views.
  • @views x[i] += y evaluated x and i twice, again a problem.
  • @views x[i[j]] = y did not use maybeview for i[j]

The @view fixes (the first commit) should probably be backported to 0.5.

(I used a workaround for #20241 here: just escaping the whole expression, with interpolated values as needed so that symbols are evaluated in the correct scope.)

@stevengj stevengj added backport pending 0.5 bugfix This change fixes an existing bug labels Jan 26, 2017
@stevengj stevengj added this to the 0.6.0 milestone Jan 26, 2017
@tkelman
Copy link
Contributor

tkelman commented Jan 26, 2017

hygiene has changed on 0.6, are you sure the bug applies on 0.5?

@stevengj
Copy link
Member Author

@tkelman, yes. On 0.5, I get:

julia> let Base = nothing, x = [1]
          @view x[1]
       end
ERROR: type Void has no field view

@StefanKarpinski
Copy link
Sponsor Member

This seems good to go. How long should we leave it?

@tkelman
Copy link
Contributor

tkelman commented Jan 26, 2017

I usually prefer once twice-around-the-clock so people in all timezones get a chance to see it.

edit: analog

@StefanKarpinski StefanKarpinski merged commit ba8468d into JuliaLang:master Jan 27, 2017
@stevengj stevengj deleted the viewsfix branch January 27, 2017 16:38
tkelman pushed a commit that referenced this pull request Mar 1, 2017
aviatesk added a commit that referenced this pull request Jan 26, 2024
The modification that expands `@view A[i]` to `true && view(A, i)`
appears to go back as far as #20247. However, I'm not entirely sure why
this is necessary. Considering that just expanding it to `view(A, i)`
still seems to pass the base test suite, I wonder if it might be
just better to get rid of that part.
aviatesk added a commit that referenced this pull request Jan 27, 2024
The modification that expands `@view A[i]` to `true && view(A, i)`
appears to go back as far as #20247. However, I'm not entirely sure why
this is necessary. Considering that just expanding it to `view(A, i)`
still seems to pass the base test suite, I wonder if it might be
just better to get rid of that part.
aviatesk added a commit that referenced this pull request Jan 29, 2024
The modification that expands `@view A[i]` to `true && view(A, i)`
appears to go back as far as #20247. However, I'm not entirely sure why
this is necessary. Considering that just expanding it to `view(A, i)`
still seems to pass the base test suite, I wonder if it might be just
better to get rid of that part.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This change fixes an existing bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants